import hbase

zk = '10.2.111.241:2182'


# zk = '10.2.111.171:24002'


def scan(tablename, namespace='default', start_row=None,end_row=None,zok=zk):
    with hbase.ConnectionPool(zok).connect() as conn:
        table = conn[namespace][tablename]
        for row in table.scan(start_row=start_row,end_row=end_row):
            print(row)


def insert(tablename, row, namespace='default', zok=zk):
    with hbase.ConnectionPool(zok).connect() as conn:
        table = conn[namespace][tablename]
        table.put(row)


if __name__ == '__main__':
    insert('baidu_currentflow', hbase.Row(
        '001', {
            'b:json': b'OAA'
        }
    ))
    # insert('T_KOMS_INTEGRAL_SUB',hbase.Row(
    #         '001', {
    #             'cf:name': b'OAA',
    #             'cf:age': b'18'
    #         }
    #     ))
    # scan('T_KOMS_INTEGRAL_SUB')
    #
    # scan('T_KOMS_INTEGRAL_SUB', start_row='00',end_row='0004')
